import {
	defineStore
} from "pinia";

export const useCartStore = defineStore('cart', {
	state: () => ({
		restaurant: {},
		cartlist: []
	}),
	actions: {
		setCart(list) {
			this.cartlist = list;
		},
		setResturant(res){
			this.restaurant = res;
		}
	},
	getters: {
		totalPrice() {
			return this.cartlist.reduce((total, item) => {
				return total + item.price * item.quantity;
			}, 0);
		}
	}
})